<template>
    <Teleport to="body">
        <div class="modal" v-if="open" @click="hide" data-name="modal">
            <div class="box">
                <p class="title">我是商品标题</p>
                <div class="content">
                    <div class="item">
                        <p class="subtitle">规格</p>
                        <div class="wrapper">
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                        </div>
                    </div>
                    <div class="item">
                        <p class="subtitle">规格</p>
                        <div class="wrapper">
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                        </div>
                    </div>
                    <div class="item">
                        <p class="subtitle">规格</p>
                        <div class="wrapper">
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                            <div class="btn">规格选项</div>
                        </div>
                    </div>
                </div>
                <div class="footer">
                    <p class="text">
                        <span class="txt">已选：</span>
                        <span class="items">规格选项、属性选项、属性选项、属性选项</span>
                    </p>
                    <div class="buy">
                        <div class="left">
                            <p>
                                <span class="price">¥18.6</span>
                                <span class="through">¥24</span>
                                <span class="ad">折扣限一份</span>
                            </p>
                        </div>
                        <div class="right">
                            <div class="btn">加入购物车
                                <div class="btn-wrapper">
                                    <div class="mius">-</div>
                                    <div class="num">2</div>
                                    <div class="add">+</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </Teleport>
</template>

<script setup>
import { ref } from 'vue';
let { open } = defineProps({ open: { type: Boolean, default: false } })
const emit = defineEmits(['hide'])
const hide = (e) => {
    if (e.target.dataset.name == 'modal') {
        // console.log(222)
        emit('hide')
    }
}

</script>

<style scoped lang="scss">
.modal {
    position: fixed;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .5);
    z-index: 999;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    .box {
        width: 340px;
        // height: 410px;
        background: #fff;
        border-radius: 10px;

        .title {
            color: #333;
            font-size: 18px;
            padding: 25px 15px;
        }

        .content {
            height: 250px;
            overflow: scroll;
            padding: 0 15px;

            .item {
                .subtitle {
                    font-size: 11px;
                    color: #999;
                    padding: 10px 0;
                }

                .wrapper {
                    // display: flex;
                    // align-items: center;
                    // justify-content: space-between;
                    // flex-wrap: wrap;
                    display: grid;
                    grid-template-columns: repeat(3, 1fr);
                    grid-gap: 5px;

                    .btn {
                        // width: 98px;
                        height: 30px;
                        border-radius: 3px;
                        text-align: center;
                        line-height: 30px;
                        box-sizing: border-box;
                        border: 1px solid #ddd;
                        font-size: 14px;
                        color: #333;
                        // margin-bottom: 5px;
                    }
                }
            }
        }

        .footer {
            .text {
                padding: 10px 15px;
                background: #fafafa;

                .txt {
                    font-size: 11px;
                    color: #666;
                }

                .items {
                    font-size: 11px;
                    color: #333;
                }
            }

            .buy {
                padding: 20px 15px;

                display: flex;
                align-items: center;
                justify-content: space-between;

                .left {

                    p {
                        display: flex;
                        align-items: center;
                    }

                    .price {
                        font-size: 22px;
                        color: #F63747;
                    }

                    .through {
                        font-size: 11px;
                        color: #999;
                        text-decoration: line-through;
                        margin: 0 5px;
                    }

                    .ad {
                        font-size: 11px;
                        color: #2493F1;
                    }
                }

                .right {
                    .btn {
                        position: relative;
                        width: 90px;
                        height: 28px;
                        background: #2493F1;
                        border-radius: 28px;
                        text-align: center;
                        line-height: 28px;
                        color: #fff;
                        font-size: 13px;

                        .btn-wrapper {
                            position: absolute;
                            width: 100%;
                            display: flex;
                            justify-content: space-around;
                            align-items: center;
                            color: #000;
                            bottom: 28px;
                            left: 0;

                            .mius {
                                width: 24px;
                                height: 24px;
                                border-radius: 50%;
                                border: 1px solid #2493F1;
                                color: #2493F1;
                                box-sizing: border-box;
                                text-align: center;
                                line-height: 24px;
                                font-size: 13px;
                            }
                            .add{
                                font-size: 13px;
                                width: 24px;
                                height: 24px;
                                text-align: center;
                                line-height: 24px;
                                background: #2493F1;
                                border-radius: 50%;
                                color:#fff;
                            }
                        }
                    }

                }
            }
        }
    }
}
</style>